home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / doc / Eval.3 < prev    next >
Text File  |  1993-02-14  |  5KB  |  123 lines

  1. '\"
  2. '\" Copyright 1989 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. .so man.macros
  11. .HS Tcl_Eval tcl
  12. .BS
  13. .SH NAME
  14. Tcl_Eval, Tcl_VarEval, Tcl_EvalFile, Tcl_GlobalEval \- execute Tcl commands
  15. .SH SYNOPSIS
  16. .nf
  17. \fB#include <tcl.h>\fR
  18. .sp
  19. int
  20. \fBTcl_Eval\fR(\fIinterp, cmd, flags, termPtr\fR)
  21. .sp
  22. int
  23. \fBTcl_VarEval\fR(\fIinterp, string, string, ... \fB(char *) NULL\fR)
  24. .sp
  25. int
  26. \fBTcl_EvalFile\fR(\fIinterp, fileName\fR)
  27. .sp
  28. .VS
  29. int
  30. \fBTcl_GlobalEval\fR(\fIinterp, cmd\fR)
  31. .VE
  32. .SH ARGUMENTS
  33. .AS Tcl_Interp **termPtr;
  34. .AP Tcl_Interp *interp in
  35. Interpreter in which to execute the command.  String result will be
  36. stored in \fIinterp->result\fR.
  37. .AP char *cmd in
  38. Command (or sequence of commands) to execute.  Must be in writable
  39. memory (Tcl_Eval makes temporary modifications to the command).
  40. .AP int flags in
  41. Either \fBTCL_BRACKET_TERM\fR or 0.
  42. If 0, then \fBTcl_Eval\fR will process commands from \fIcmd\fR until
  43. it reaches the null character at the end of the string.
  44. If \fBTCL_BRACKET_TERM\fR,
  45. then \fBTcl_Eval\fR will process comands from \fIcmd\fR until either it
  46. reaches a null character or it encounters a close bracket that isn't
  47. backslashed or enclosed in braces, at which point it will return.
  48. Under normal conditions, \fIflags\fR should be 0.
  49. .AP char **termPtr out
  50. If \fItermPtr\fR is non-NULL, \fBTcl_Eval\fR fills in *\fItermPtr\fR with
  51. the address of the character just after the last one in the last command
  52. successfully executed (normally the null character at the end of \fIcmd\fR).
  53. If an error occurs in the first command in \fIcmd\fR, then \fI*termPtr\fR
  54. will be set to \fIcmd\fR.
  55. .AP char *string in
  56. String forming part of Tcl command.
  57. .AP char *fileName in
  58. Name of file containing Tcl command string.
  59. .BE
  60.  
  61. .SH DESCRIPTION
  62. .PP
  63. All four of these procedures execute Tcl commands.
  64. \fBTcl_Eval\fR is the core procedure:  it parses commands
  65. from \fIcmd\fR and executes them in
  66. order until either an error occurs or \fBTcl_Eval\fR reaches a terminating
  67. character (']' or '\e0', depending on the value of \fIflags\fR).
  68. The return value from \fBTcl_Eval\fR is one
  69. of the Tcl return codes \fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or
  70. \fBTCL_CONTINUE\fR, and \fIinterp->result\fR will point to
  71. a string with additional information (result value or error message).
  72. This return information corresponds to the last command executed from
  73. \fIcmd\fR.
  74. .PP
  75. \fBTcl_VarEval\fR takes any number of string arguments
  76. of any length, concatenates
  77. them into a single string, then calls \fBTcl_Eval\fR to
  78. execute that string as a Tcl command.
  79. It returns the result of the command and also modifies
  80. \fIinterp->result\fR in the usual fashion for Tcl commands.  The
  81. last argument to \fBTcl_VarEval\fR must be NULL to indicate the end
  82. of arguments.
  83. .PP
  84. \fBTcl_EvalFile\fR reads the file given by \fIfileName\fR and evaluates
  85. its contents as a Tcl command by calling \fBTcl_Eval\fR.  It returns
  86. a standard Tcl result that reflects the result of evaluating the
  87. file.
  88. If the file couldn't be read then a Tcl error is returned to describe
  89. why the file couldn't be read.
  90. .PP
  91. .VS
  92. \fBTcl_GlobalEval\fR is similar to \fBTcl_Eval\fR except that it
  93. processes the command at global level.
  94. This means that the variable context for the command consists of
  95. global variables only (it ignores any Tcl procedure that is active).
  96. This produces an effect similar to the Tcl command ``\fBuplevel 0\fR''.
  97. .VE
  98. .PP
  99. During the processing of a Tcl command it is legal to make nested
  100. calls to evaluate other commands (this is how conditionals, loops,
  101. and procedures are implemented).
  102. If a code other than
  103. \fBTCL_OK\fR is returned from a nested \fBTcl_Eval\fR invocation, then the
  104. caller should normally return immediately, passing that same
  105. return code back to its caller, and so on until the top-level application is
  106. reached.  A few commands, like \fBfor\fR, will check for certain
  107. return codes, like \fBTCL_BREAK\fR and \fBTCL_CONTINUE\fR, and process them
  108. specially without returning.
  109. .PP
  110. \fBTcl_Eval\fR keeps track of how many nested Tcl_Eval invocations are
  111. in progress for \fIinterp\fR.
  112. If a code of \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR is
  113. about to be returned from the topmost \fBTcl_Eval\fR invocation for
  114. \fIinterp\fR, then \fBTcl_Eval\fR converts the return code to \fBTCL_ERROR\fR
  115. and sets \fIinterp->result\fR to point to an error message indicating that
  116. the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was
  117. invoked in an inappropriate place.  This means that top-level
  118. applications should never see a return code from \fBTcl_Eval\fR other then
  119. \fBTCL_OK\fR or \fBTCL_ERROR\fR.
  120.  
  121. .SH KEYWORDS
  122. command, execute, file, global, interpreter, variable
  123.